package com.example.android.adapters

import android.util.Log
import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter
import androidx.viewpager.widget.ViewPager

/**
 * @ClassName AnnounceViewPagerAdapter
 * @Author Ryan Kamanri
 * @Date 2022/6/1
 * @Description
 **/
class AnnounceViewPagerAdapter(private val views: ArrayList<View>, private val titles: ArrayList<String>): PagerAdapter() {
    override fun getCount(): Int {
        return views.size
    }

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view == `object`
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val view = views[position]
        container.addView(view)
        return view
    }

    override fun getPageTitle(position: Int): CharSequence {
        return titles[position]
    }

}